<?php
/*=============================================================================
|| ##################################################################
||	phpFoX Konsort
|| ##################################################################
||	
||	Copyright		: (C) 2005-2007 PHPFOX Limited a Reality Fox Creation
||	Contact			: info@phpfox.com
||
||	- phpFoX and all of its source code and files are protected by Copyright Laws. 
||
||	- The license for phpFoX permits you to install this software on a single domain (.com, .org, .net, etc.). 
||
||	- You may also not remove this copyright screen which shows the copyright information and credits for phpFoX (RealityFOX Creations). 
||
||	- phpFoX Konsort is NOT a FREE software - http://www.phpfox.com/license/
||
|| ##################################################################
=============================================================================*/

/* $File: ./site/public/check-im.php, $Author:  $ */

    global $_CONF;
    $_CONF['debug'] = 0;
    
    $oSrvChat = &App::getModuleService('Chat', 'Chat');
    $oSrvSec = &App::getModuleService('Account', 'Security');
    $oUser = $oSrvSec->getCurrentUser();
    if ($oUser and $oUser->aData['user'])
    {
        $aRes = $oSrvChat->checkMessenger($oUser->aData['user']);
    }
    $bAlert = false;
    
    if(isset($aRes) and !empty($aRes))
        $bAlert = true;

    header("Expires: Mon, 26 Jul 1997 05:00:00 GMT" ); 
    header("Last-Modified: " . gmdate( "D, d M Y H:i:s" ) . "GMT" ); 
    header("Cache-Control: no-cache, must-revalidate" ); 
    header("Pragma: no-cache" );
    header("Content-Type: text/xml; charset=utf-8");
    
    $css_bg_color = "#00004D";

	$css_border = "2px #b70000 solid";

	$css_text_color = "#fff";

	$media = "";
	$sUrl = App::makeUrl('public.account.chat');
	$file = '';
	if($bAlert)
	{
        $file = htmlspecialchars(''. $media .'<div style="padding:5px;background:'. $css_bg_color .';border:'. $css_border .';font-size:9pt;"><br /><a href="javascript:void(0);" onclick="popUp2(\''.$sUrl.'\',\'730\',\'550\',\'yes\',\'200\',\'100\');" style="color:'. $css_text_color .';">Live Chat Alert - Click here to find who wants to chat.</a>  <br /> <br /></div>');
	}
    $xml = '<?xml version="1.0" ?><root>';
    $xml .= '<message id="1">';
    if($bAlert)
    	$xml .= '<user>'. $file .'</user>';
    $xml .= '<time>34343</time>';
    $xml .= '</message>';
    $xml .= '</root>';
    echo $xml;


	$oTpl = &App::getTemplate();
	$oTpl->setTemplateFile('check-im.html');
?>